﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Mobwiz.SpellChecker.Core;

namespace SpellCheckerTest
{
    class Program
    {
        static void Main(string[] args)
        {            
            string dictPath = @"dict.dat";
            string phonetPath = @"en_phonet.dat";

            // initialize
            IPhonet phonet = new Mobwiz.SpellChecker.Core.Phonets.AspellPhonet(phonetPath);
            ISpellDictionary dictionary = new Mobwiz.SpellChecker.Core.Dictionaries.MemoryDictionary();
            dictionary.LoadDictionary(dictPath);

            SpellChecker checker = new SpellChecker(phonet, dictionary);


            while (true)
            {
                Console.Clear();
                Console.Write("Input a word:");
                string word = Console.ReadLine();
                if (checker.CheckWord(word))
                {
                    Console.WriteLine("Correct!");
                }
                else
                {
                    var suggest = checker.GetSuggestWords(word);
                    Console.WriteLine("Misspelled!");
                    Console.WriteLine("Suggested words below:");

                    int a = 1;
                    foreach (var sug in suggest)
                    {
                        Console.WriteLine(string.Format("{0} : {1} - {2}", a++, sug.Word, sug.EditDistance));
                    }
                }
                Console.ReadKey();
            }
        }
    }
}
